/**
 * 详情对话框
 */
var TPollutantsFactorInfoDlg = {
    data: {
        orificeId: "",
        pollutantFactor: "",
        emissionRate: "",
        concentration: "",
        remark: "",
        createTime: "",
        delFlag: "",
        monitoringId: "",
        windType: "",
        isOrganization: "",
        isInside: ""
    }
};

var pid =  Feng.getUrlParam("pid");

var windType =  Feng.getUrlParam("windType");

layui.use(['form', 'admin', 'ax'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //获取详情信息，填充表单
    var ajax = new $ax(Feng.ctxPath + "/tPollutantsFactor/detail?id=" + Feng.getUrlParam("id"));
    var result = ajax.start();
    form.val('tPollutantsFactorForm', result.data);
    var  sb = document.getElementById("pollutantsName");
    var  nb = document.getElementById("emissionRateName");
     if(pid != null || windType != null){
           sb.style.display = "none"
         nb.style.display = "none"
     } else {
         sb.style.display = "block"
         nb.style.display = "block"
     }

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/tPollutantsFactor/editItem", function (data) {
            if(data.code == 200) {
                Feng.success("更新成功！");
            }else{
                Feng.error("更新失败！" + data.message)
            }

            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);

            //关掉对话框
            admin.closeThisDialog();

        }, function (data) {
            Feng.error("更新失败！" + data.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

    /*监听排放口名称*/
    var ajax1 = new $ax(Feng.ctxPath + "/tExhaustOrifice/basicList");
    var orificeList = ajax1.start();
    console.log(orificeList);
    for (var i = 0 ; i < orificeList.length ; i++){
        $("#orificeId").append("<option value=\"" + orificeList[i].id + "\">" + orificeList[i].orificeName + "</option>");
    }
    //重新渲染
    layui.form.render("select");
});